package mess;

public class LeeCode_20 {
    public static void main(String[] args) {
        String s = "[]()(){}[]";
        System.out.println(isValid(s));

    }
    private static boolean isValid(String s) {
        /*int one = 0;
        int two = 0;
        int three = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            switch (c){
                case '(':
                    one++;
                    break;
                case '{':
                    two++;
                    break;
                case '[':
                    three++;
                    break;
                case ')':
                    one--;
                    break;
                case '}':
                    two--;
                    break;
                case ']':
                    three--;
                    break;
                default:
                    break;
            }
        }
        if (one == 0 && two == 0 && three == 0)
            return true;
        return false;*/
        int len = s.length() / 2;
        for (int i = 0; i < len; i++) {
            s = s.replace("()", "").replace("[]", "").replace("{}", "");
        }
        return s.length() == 0;
    }
}
